package controller.student;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpSession;

/**
 * 学生页面控制器
 */
@Controller
@RequestMapping(value = {"/student"})
public class StudentPageController {

    /**
     * 学生控制台界面
     */
    @GetMapping("/console")
    public ModelAndView studentConsole(HttpServletRequest request){
        HttpSession session = request.getSession();

        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("StudentInfo",session.getAttribute("UserInfo"));
        modelAndView.setViewName("/jsp/student/Console.jsp");

        return modelAndView;
    }

    /**
     * 学生控制台主界面
     */
    @GetMapping("/frame/index")
    public ModelAndView consoleIndex(){
        ModelAndView modelAndView = new ModelAndView();
        modelAndView.setViewName("/jsp/student/Frame-Index.jsp");
        return modelAndView;
    }

    /**
     * 学生信息管理界面
     */
    @GetMapping("/frame/personalInfo")
    public ModelAndView studentInfoManager(HttpServletRequest request){
        HttpSession session = request.getSession();

        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("StudentInfo",session.getAttribute("UserInfo"));
        modelAndView.setViewName("/jsp/student/Frame-PersonalInfo.jsp");

        return modelAndView;
    }

    /**
     * 学生修改基础信息页
     */
    @GetMapping("/frame/changeBaseInfo")
    public ModelAndView studentChangeBaseInfoPage(HttpServletRequest request){
        HttpSession session = request.getSession();

        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("StudentInfo",session.getAttribute("UserInfo"));
        modelAndView.setViewName("/jsp/student/Frame-ChangeBaseInfo.jsp");

        return modelAndView;
    }

    /**
     * 学生修改登录信息页
     */
    @GetMapping("/frame/changeLoginInfo")
    public ModelAndView studentChangeLoginInfoPage(HttpServletRequest request){
        HttpSession session = request.getSession();

        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("StudentInfo",session.getAttribute("UserInfo"));
        modelAndView.setViewName("/jsp/student/Frame-ChangeLoginInfo.jsp");

        return modelAndView;
    }

    /**
     * 学生修改联系信息页
     */
    @GetMapping("/frame/changeConnect")
    public ModelAndView studentUpdateConnectPage(HttpServletRequest request){
        HttpSession session = request.getSession();

        ModelAndView modelAndView = new ModelAndView();
        modelAndView.addObject("UserInfo",session.getAttribute("UserInfo"));
        modelAndView.setViewName("/jsp/student/Frame-ChangeConnectInfo.jsp");

        return modelAndView;
    }

    /**
     * 学生修改头像信息页
     */
    @GetMapping("/frame/student-alter-avatar")
    public String studentAlterAvatar(){
        return "forward:/pages/student/Console-Frame-UpdateAvatar.html";
    }

    /**
     * 学生课程信息页
     */
    @GetMapping("/frame/my-course")
    public String studentClassInfoPage(){
        return "forward:/pages/student/Console-Frame-ClassInfo.html";
    }
}
